Use dfClient.pkg
Use DataDict.pkg
Use Windows.pkg

Use ROSTER.DD

DEFERRED_VIEW Activate_oLocalWorkRoster FOR ;
;
Object oLocalWorkRoster is a dbView

    Property String psMBIMportLabel "Import Rosters"

    Set Border_Style to Border_Thick
    Set Label to "Learn Request_Assign et al."
    Set Location to 1 1
    Set Size to 223 253

    Object oRoster_DD is a Roster_DataDictionary
    End_Object

    Set Main_DD to oRoster_DD
    Set Server to oRoster_DD

    Object oTextBox1 is a Textbox
        Set Label to "This will add or overwrite the player (ROSTER) record."
        Set Location to 19 23
        Set Size to 10 171
        Set TypeFace to "MS Sans Serif"
    End_Object    // oTextBox1

    Object oTextBox2 is a TextBox
        Set Size to 10 197
        Set Location to 4 23
        Set Label to "Learn Request_Assign, Request_Save,  and Request_Delete."
    End_Object


    Object oRosterGrp is a Group
        Set Size to 87 221
        Set Location to 32 12
        Set Label to "Roster"

        Object oJersey is a Form
            Set Label to "Jersey"
            Set Size to 13 44
            Set Location to 22 7
            Set Label_Col_Offset to 0
            Set Label_Justification_Mode to jMode_Top
        End_Object    // oJersey

        Object oLastName is a Form
            Set Label to "Last Name"
            Set Size to 13 52
            Set Location to 22 63
            Set Label_Col_Offset to 0
            Set Label_Justification_Mode to jMode_Top
        End_Object    // oLastName

        Object oFirstName is a Form
            Set Label to "First Name"
            Set Size to 13 46
            Set Location to 22 125
            Set Label_Col_Offset to 0
            Set Label_Justification_Mode to jMode_Top
        End_Object    // oFirstName

        Object oPosition is a Form
            Set Label to "Position"
            Set Size to 13 39
            Set Location to 49 8
            Set Label_Col_Offset to 0
            Set Label_Justification_Mode to jMode_Top
        End_Object    // oPosition

        Object oHeightFt is a Form
            Set Label to "Height Feet"
            Set Size to 13 41
            Set Location to 49 63
            Set Label_Col_Offset to 0
            Set Label_Justification_Mode to jMode_Top
        End_Object    // oHeightFt

        Object oHeightIn is a Form
            Set Label to "Height Inch"
            Set Size to 13 35
            Set Location to 49 117
            Set Label_Col_Offset to 0
            Set Label_Justification_Mode to jMode_Top
        End_Object    // oHeightIn

        Object oWeight is a Form
            Set Label to "Weight"
            Set Size to 13 41
            Set Location to 49 164
            Set Label_Col_Offset to 0
            Set Label_Justification_Mode to jMode_Top
        End_Object    // oWeight

        Object oCreateEdit is a Button
            Set Label to "Create/Edit"
            Set Location to 67 154

            Procedure OnClick
                String sLastName sFirstName sPosition
                Integer iNum iHeightFeet iHeightInch iWeight

                Get value of oJersey to iNum
                Get value of oLastName to sLastName
                Get value of oFirstName to sFirstname
                Get value of oPosition to sPosition
                Get value of oHeightFt to iHeightFeet
                Get value of oHeightIn to iHeightInch
                Get value of oWeight to iWeight

                Send DoCreateEdit iNum sLastName sFirstName sPosition iHeightFeet iHeightInch iWeight
            End_Procedure

        End_Object  
    End_Object 

    Object oDeleteGrp is a dbGroup
        Set Size to 68 223
        Set Location to 139 12
        Set Label to "Delete Player"
        Object oJerseyDelete is a Form
            Set Label to "Jersey"
            Set Size to 13 85
            Set Location to 28 14
            Set Label_Col_Offset to 0
            Set Label_Justification_Mode to jMode_Top
        End_Object

        Object oDelete is a Button
            Set Label to "Delete"
            Set Location to 26 153

            Procedure OnClick
                Integer iJersey

                Get value of oJerseyDelete to iJersey
                Clear Roster
                Move iJersey to Roster.Num
                Find EQ Roster by Index.1
                If (Found) Begin
                    // no parent, so we don't need to Relate
                    Send Request_Assign of oRoster_DD Roster.File_number
                    Send Request_Delete of oRoster_DD
                End
                 Else Send Info_Box ("Jersey " + (string(iJersey)) + " was not found in database")
            End_Procedure

        End_Object

    End_Object


    Procedure DoCreateEdit integer iNum string sLastName string sFirstName string sPosition integer iHeightFeet integer iHeightInch integer iWeight
        Boolean bFail

        Send Clear of oRoster_DD

        Move iNum to Roster.Num
        Find EQ Roster by Index.1
        If (found) Begin
            // no parent, so we don't need to Relate
            Send Request_Assign of oRoster_DD Roster.File_Number
        End
         Else Begin
            Set Field_Changed_Value of oRoster_DD Field Roster.Num to iNum
         End
        Set Field_Changed_Value of oRoster_DD Field Roster.Last_name   to sLastName
        Set Field_Changed_Value of oRoster_DD Field Roster.First_name  to sFirstName
        Set Field_Changed_Value of oRoster_DD Field Roster.Pos         to sPosition
        Set Field_Changed_Value of oRoster_DD Field Roster.Height_feet to iHeightFeet
        Set Field_Changed_Value of oRoster_DD Field Roster.Height_inch to iHeightInch
        Set Field_Changed_Value of oRoster_DD Field Roster.Weight      to iWeight

        Get Request_Validate of oRoster_DD to bFail
        If (not(bFail)) Begin
            Send Request_Save of oRoster_DD
            Move (Should_Save(oRoster_DD)) to bFail
        End
        If (bFail) Send Info_box "Unable to save Rosters record" (psMBImportLabel(self))

    End_Procedure


    //jhs### for ease of testing only.  Must remove before shipping
    Procedure Page_Object integer itype

        Forward Send page_object itype

        Set value of oJersey to 66
        Set value of oLastName to "TestLast"
        Set value of oFirstName to "TestFirst"
        Set value of oPosition to "G"
        Set value of oHeightFt to 6
        Set value of oHeightIn to 4
        Set value of oWeight to 200
    End_Procedure

CD_End_Object 
